/**
 *******************************************************************************
 * @FileName  : kv_api.h
 * @Author    : GaoQiu
 * @CreateDate: 2024年5月25日
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#ifndef _KV_API_H_
#define _KV_API_H_

#include "kv_type.h"

/* kv error code define */
#define KV_OK                            0     /* Success */
#define KV_CONTINUE                    200
#define KV_ERR_INVALID_CONFIG         -201
#define KV_ERR_INVALID_PARAMS         -202
#define KV_ERR_MEM_ALLOC_FAILED       -203
#define KV_ERR_FLASH_WRITE_FAILED     -204
#define KV_ERR_FLASH_READ_FAILED      -205
#define KV_ERR_FLASH_ERASE_FAILED     -206
#define KV_ERR_BLOCK_FULL             -207
#define KV_ERR_HAS_NO_EMPTY_BLOCK     -208
#define KV_ERR_NO_FOUND               -209

int kv_init(void);

int kv_set_item(char *key, uint8_t *value, uint32_t len);
int kv_get_item(char *key, uint8_t *buf, uint32_t *bufLen);
uint32_t kv_get_item_ex(char *key, uint8_t *buf, uint32_t bufLen);
int kv_del_item(char *key);


#define KV_TEST_EN    0
#if KV_TEST_EN
void kv_test_set_item(void);
void kv_test_get_item(void);
void kv_test_del_item(void);
void kv_printf(void);
void kv_printf_all_item(void);
#endif

#endif /* _KV_API_H_ */
